package com.gjh.service.company.impl;


import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gjh.dao.company.CompanyDao;
import com.gjh.domain.company.Company;
import com.gjh.service.company.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;

@Service
public class CompanyServiceImpl implements CompanyService {

    @Autowired
    private CompanyDao companyDao;
    @Override
    public List<Company> findAll() {
        return companyDao.findAll();
    }
//保存公司信息
    @Override
    public void save(Company company) {
        companyDao.save(company);
    }

    @Override
    public void update(Company company) {
        companyDao.update(company);
    }

    @Override
    public Company findById(String id) {
        return companyDao.findByID(id);
    }

    @Override
    public void deleteById(String id) {
        companyDao.deleteById(id);
    }

    @Override
    public PageInfo findByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Company> list=companyDao.findAll();
        return new PageInfo(list,5);
    }

    /*@Override
    public PageBean<Company> findByPage(PageBean pageBean) {
        Integer totalCount=companyDao.findCount();
        pageBean.setTotalCount(totalCount);
        //计算总页数分装
        Integer totalPage=new Double(Math.ceil(totalCount*1.0/pageBean.getPageSize())).intValue();
        pageBean.setTotalPage(totalPage);
        //计算开始索引
        Integer index=(pageBean.getPageNum()-1)*pageBean.getPageSize();

        List<Company> list=companyDao.findByPage(index,pageBean.getPageSize());
        pageBean.setList(list);
        return pageBean;
    }*/

}
